/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import model.dao.util.MySqlDataAccessHelper;

/**
 *
 * @author TiOc
 */
public class ThamSoDAO
{
    public static int laySoLuongSanPhamTrenTrang(int maThamSo)
    {
        int soLuong = -1;
        String sql = String.format("SELECT SoSanPhamTrenTrang FROM ThamSo WHERE MaThamSo = %d", maThamSo);
        MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
        helper.open();
        ResultSet rs = helper.executeQuery(sql);
        try
        {
            if(rs.next())
            {
                soLuong = rs.getInt("SoSanPhamTrenTrang");
            }
        }
        catch(SQLException ex)
        {
            System.out.print(ex.getMessage());
        }
        helper.close();
        
        return soLuong;
    }
}
